package com.zhw.controller;

import com.zhw.pojo.PageBean;
import com.zhw.pojo.Result;
import com.zhw.pojo.dto.ServeQueryDTO;
import com.zhw.pojo.entry.CustomerServe;
import com.zhw.service.CustomerServeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("customerServe")
@Slf4j
public class CustomerServeController {

    @Autowired
    CustomerServeService customerServeService;

    @GetMapping("page")
    public Result page(ServeQueryDTO serveQueryDTO){
        log.info("分页查询服务信息：{}",serveQueryDTO);
        PageBean page=customerServeService.page(serveQueryDTO);
        return Result.success(page);
    }

    @PostMapping("add")
    public Result save(@RequestBody CustomerServe customerServe){
        log.info("创建一个服务：{}",customerServe);
        customerServeService.save(customerServe);
        return Result.success();
    }


    @GetMapping("getServeByIdAndStatus")
    public Result getServeByIdAndStatus(Integer id,Integer status){
        log.info("查询当前状态：{}ID：下的记录",status,id);
        CustomerServe customerServe=customerServeService.getServeByIdAndStatus(id,status);
        return Result.success(customerServe);
    }


    @PutMapping("assignment")
    public Result assignment(@RequestBody CustomerServe customerServe){
        log.info("分配服务：{}",customerServe);
        customerServeService.assignment(customerServe);
        return Result.success();
    }


    @GetMapping("getDiopose")
    public Result getDiopose(ServeQueryDTO serveQueryDTO){
        log.info("获取到分配信息");
        PageBean pb=customerServeService.getDisPose(serveQueryDTO);
        return Result.success(pb);
    }



    @PutMapping("dispose")
    public Result dispose(@RequestBody CustomerServe customerServe){
        log.info("处理服务：{}",customerServe);
        customerServeService.dispose(customerServe);
        return Result.success();
    }



    @PutMapping("feedback")
    public Result feedback(@RequestBody CustomerServe customerServe){
        log.info("服务的反馈：{}",customerServe);
        customerServeService.feedback(customerServe);
        return Result.success();
    }
}
